<html>
  <head>
    <meta charset="utf-8"> 
    <title>美业红</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="http://apps.bdimg.com/libs/bootstrap/3.2.0/css/bootstrap.min.css">
    <script type='text/javascript' src='/public/js/jquery-1.11.2.min.js'></script>
    <script type="text/javascript" src='/public/js/jquery.validate.js'></script>       
  </head>
  <body>
  	
  
  	<?php if($action){?> 
    <div class="table-responsive"> 
                        <table  class="table table-striped table-bordered" style=" margin-top:3rem;"  >
                          <thead>
                            <tr>
                                <th>活动名称</th>
                                <th>门店名称</th>
                                <th>发型师</th>
                                <th width="22%">活动时间</th>
                                <th>活动类型</th>
                                <th width="20%">门店地址</th>
                            </tr>
                          </thead>
                          <tbody>
                            <?php foreach($action as $v){  ?>
                            <tr>
                                <td><?php echo $v['action_name']?></td>
                                <td><?php echo $v['store_id']?></td>
                                <td><?php echo $v['barber_id']?></td>
                                <?php if($v['status']==1){?>
                                <td><?php echo date("Y年m月d日",$v['start_time'])?>--<?php if($v['end_time']>time()){echo date("Y年m月d日",$v['end_time']),"---(进行中)";}else{ echo date("Y年m月d日",$v['end_time']),"---(已结束)";}?></td>
                                <?php }else{?>
                                <td><?php echo date("Y年m月d日",$v['start_time'])?>--<?php echo date("Y年m月d日",$v['end_time']);?></td>
                                <?php }?>
                                <td><?php echo $v['model_type']?></td>
                                <td><?php echo $v['store_address']?></td>
                            </tr>
                            <?php }  ?>
                            <tr><td  colspan=6 align='center'><?php echo $page;?></td><tr>
                         </tbody>   	
                        </table>
     </div>                   
    <?php }elseif($order){  ?>
    <nav class="navbar navbar-default" role="navigation">
      <div class="container-fluid"> 
      <div class="navbar-header">
          <a class="navbar-brand" href="#">美业红</a>
      </div>
      <div>
          <form class="navbar-form navbar-left" role="search" >
              <div class="form-group">
                  <input type="text" class="form-control" placeholder="请输入订单号/手机号" name='Search' id='Search' value="<?php if($search){ echo $search;} ?>" >
                  <input type="text" class="form-control" placeholder="请输入门店名称" name='store' id='store' value="<?php if($store){ echo $store;} ?>">
                  <select id="status" name="status" class="form-control"  >
                      <option value="0" <?php if($status == 0){ echo 'selected="selected"';}?> >全部状态</option>
                      <option value="3" <?php if($status == 3){ echo 'selected="selected"';}?> >已完成</option>
                      <option value="2" <?php if($status == 2){ echo 'selected="selected"';}?> >已付定金</option>
                      <option value="1" <?php if($status == 1){ echo 'selected="selected"';}?> >未完成</option>
                  </select>
                  <input type="text" class="form-control" name='start_time' placeholder="开始时间" id='start_time' value="<?php if($time1){ echo $time1;} ?>" onfocus="WdatePicker();" onblur=""/>
                  <input type="text" class="form-control" name='end_time' id='end_time' placeholder="结束时间" value="<?php if($time2){ echo $time2;} ?>" onfocus="WdatePicker();" onblur=""/>
              </div>
              <button type="button" class="btn btn-default" onclick='_submit()' >查询</button>
              <button type="button" class="btn btn-default" onclick='_print()' >导出</button>
          </form>

      </div>
      </div>
    </nav>
    <div class="table-responsive">
      <div style='text-align:center;font-size:2rem;' > 共有<span style="color:red" ><?php echo $count; ?></span>条记录 </div>
                        <table class="table table-striped table-bordered">
                         <thead style='text-align:center;'>
                            <tr >
                                <th>订单号</th>
                                <th>门店名称</th>
                                <th>手机号</th>
                                <th>发型师</th>
                                <th>参加活动</th>
                                <th>金额</th>
                                <th>下单时间</th>
                                <th>是否支付</th>
                                <th>类型</th>
                                <th width="20%">门店地址</th>
                            </tr>
                         </thead>
                         <tbody>    
                            <?php foreach($order as $v){  ?>
                            <tr>
                                <td><?php echo $v['order_number']?></td>
                                <td><?php echo $v['store_id']?></td> 
                                <td><?php echo $v['mobile']?></td>                               
                                <td><?php echo $v['barber_id']?></td>
                                <td><?php if($v['action_id']){ echo $v['action_id'];}else{ echo "商城订单";}?></td>
                                <td><?php echo $v['price']/100,'元';?></td>
                                <td><?php echo date("Y年m月d日",$v['create_time'])?></td>
                                <td><?php if($v['status'] == 0){echo '否';}else{echo '是';}?></td>
                                <td><?php if($v['model_type']){ echo $v['model_type'];}else{ echo '商城';}?></td>
                                <td><?php echo $v['store_address']?></td>
                            </tr>
                            <?php } ?>
                            <tr><td  colspan=10 align='center'><?php echo $page;?></td></tr>
                          </tbody>
                        </table>
      </div> 
                       <?php }  ?> 
<div id='show' style="text-align:center;width:100%;height:100%;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#8E8E8E',endColorstr='##8E8E8E');
background-color:rgba(0, 0,0, 0.5);position:fixed; _position:absolute; top:0;left:0; z-index:5000;display:none "> 
  <div style='width:30rem;margin: 25rem auto;background-color: white;'  >
    <img width='25px'; onclick='_hide()' style='float:right;margin-top:-1rem;margin-right:-1rem' src='/public/images/error1.png' >
    <div style='padding:4rem;'>
         <form  action="/admin/index/prints" method="post" id='forms'>

            开始时间：
            <input type="text" class="row _minput" name='time1' placeholder="" id='time1' value="" onfocus="WdatePicker();" onblur=""/>
            <input type="hidden" value="" name="_Search" id='_Search' /><br />
             <input type="hidden" value="" name="_status" id='_status' /><br />
            结束时间：
             <input type="text" class="row _minput" name='time2' id='time2' placeholder="" value="" onfocus="WdatePicker();" onblur=""/>
            <input type="hidden" value="" name="_store" id='_store' /><br />
            
        </form>
        <button class="btn btn-primary btn-lg"  type="button" onclick='_submits()' style="width:30%;background-color:#dddddd;border-color:#dddddd;color:black;">确定</button>
        <div class='_line'></div>
    </div>    
  </div>

</div>  
<div class='_line'></div>                                
   </body>
   <script type='text/javascript' src='/public/js/date/WdatePicker.js'></script> 
<script type="text/javascript">
  function _submit(){
    Search = $('#Search').val();
    store = $.trim($('#store').val());
    status = $('#status').val();
    time1 = $('#start_time').val();
    time2 = $('#end_time').val();
    window.location.href = "/admin/Index/search?Search="+Search+"&store="+store+"&status="+status+"&time1="+time1
    +"&time2="+time2;
  }

  function _print(){
    Search = $('#Search').val();
    store = $('#store').val();
    status = $('#status').val();
    time1 = $('#start_time').val();
    time2 = $('#end_time').val();
    $('#_Search').val(Search);
    $('#_store').val(store);
    $('#_status').val(status);
    $('#time1').val(time1);
    $('#time2').val(time2);
    $('#show').show();
  }

  function _hide(){
     $('#show').hide();
  }

  function _submits(){
    var time1 = $('#time1').val();
    var time2 = $('#time2').val();
    time1 = (Date.parse(time1))/1000;
    time2 = (Date.parse(time2))/1000+86399;
    if((time2-time1)>2678401){
      alert('日期最长为一个月');
      return;
    }
    $('#forms').submit();
  }
</script>
  </html>                

